home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / util / libs / regex.lha / regex / Docs / regex.doc < prev    next >
Encoding:
Text File  |  1999-04-23  |  11.6 KB  |  255 lines

  1. TABLE OF CONTENTS
  2.  
  3.  
  4. regex.library/--rexxhost--
  5. regex.library/--structures--
  6. regex.library/regcomp
  7. regex.library/regerror
  8. regex.library/regexec
  9. regex.library/regfree
  10. regex.library/--rexxhost--                  regex.library/--rexxhost--
  11.  
  12.     HOST INTERFACE
  13.      regex.library provides an ARexx functions interface, with offset -30,
  14.      offering to ARexx macro just one funcion, for now, :
  15.  
  16.      REMATH
  17.      Usage: res = rematch(regex,string,flags,pmatch)
  18.      <regexp>,<string>,[flags],[pmath/V]
  19.  
  20.      Verify is regex , a regular expression, matches string , returning
  21.      0 on succes or a positive regex error code. The error string
  22.      can be found in REGERR on failure.
  23.  
  24.      If flags is specified, it is one or more of:
  25.      - ICASE Compile for matching that ignores upper/lower case distinctions.
  26.      - OLD   Compile obsolete (``basic'') REs, rather than the modern
  27.              (``extended'') REs that are the default.
  28.      - NEWLINE Compile for newline-sensitive matching.
  29.      - STARTEND pmatch.SO is the start offset
  30.                 pmatch.EO-1 is the end offset
  31.                 pmatch must be specified
  32.  
  33.      If pmatch is specified, the fields:
  34.      - SO index of the first character that matches
  35.      - EO index of the character after the last that matches
  36.      are set.
  37. regex.library/--structures--                    regex.library/--structures--
  38.  
  39.     STRUCTURES
  40.  
  41.      The header <regex.h> declares two structure types:
  42.      - regex_t
  43.      - regmatch_t
  44.      The former for compiled internal forms and the latter for match reporting.
  45.  
  46.      It also declares the four functions, a type regoff_t, and a number of
  47.      constants with names starting with REG_ .
  48. regex.library/regcomp                           regex.library/regcomp
  49.  
  50.     NAME
  51.      regcomp -- compiles a regular expression.
  52.  
  53.     SYNOPSIS
  54.      err =  regcomp(preg,pattern,cflags);
  55.                     a0   a1      d0
  56.  
  57.      int regcomp(regex_t *preg, const char *pattern, int cflags);
  58.  
  59.     FUNCTION
  60.      Compiles the regular expression contained in the pattern string,
  61.      subject to the flags in cflags and places the results in the
  62.      regex_t structure pointed to by preg .
  63.      An internal pool in the library base is used to hold any allocated
  64.      resource. The memory is freed asap.
  65.  
  66.  
  67.     INPUTS
  68.      preg - a pointer to a regex_t where the regular expression wil be written
  69.      pattern - the regular expression string
  70.      Cflags - is the bitwise OR of zero or more of the following flags:
  71.      REG_EXTENDED Compile modern (``extended'') REs,
  72.                   rather than the obsolete (``basic'') REs that
  73.                   are the default.
  74.      REG_BASIC    This is a synonym for 0, provided as a counterpart
  75.                   to REG_EXTENDED to improve readability.
  76.      REG_NOSPEC   Compile with recognition of all special characters
  77.                   turned off. All characters are thus considered ordinary,
  78.                   so the ``RE'' is a literal string.
  79.                   This is an extension, compatible with but not specified
  80.                   by POSIX 1003.2, and should be used with caution in software
  81.                   intended to be portable to other systems.
  82.                   REG_EXTENDED and REG_NOSPEC may not be used in the same call
  83.                   to regcomp .
  84.      REG_ICASE    Compile for matching that ignores upper/lower case distinctions.
  85.      REG_NOSUB    Compile for matching that need only report success or failure,
  86.                   not what was matched.
  87.      REG_NEWLINE  Compile for newline-sensitive matching. By default, newline
  88.                   is a completely ordinary character with no special meaning
  89.                   in either REs or strings. With this flag, `[^' bracket
  90.                   expressions and `.' never match newline, a `^' anchor matches
  91.                   the null string after any newline in the string in addition to
  92.                   its normal function, and the `$' anchor matches the null string
  93.                   before any newline in the string in addition to its normal
  94.                   function.
  95.      REG_PEND     The regular expression ends, not at the first NUL, but just
  96.                   before the character pointed to by the re_endp member of the
  97.                   structure pointed to by preg . The re_endp member is of type
  98.                   const char * . This flag permits inclusion of NULs in the RE;
  99.                   they are considered ordinary characters.
  100.                   This is an extension, compatible with but not specified
  101.                   by POSIX 1003.2, and should be used with caution in software
  102.                   intended to be portable to other systems.
  103.  
  104.     RESULT
  105.      When successful, regcomp returns 0 and fills in the structure pointed to by
  106.      preg . One member of that structure (other than re_endp) is publicized:
  107.      re_nsub , of type size_t , contains the number of parenthesized
  108.      subexpressions within the RE (except that the value of this member is
  109.      undefined if the REG_NOSUB flag was used).
  110.      If regcomp fails, it returns a non-zero error code.
  111. regex.library/regerror                          regex.library/regerror
  112.  
  113.     NAME
  114.      regerror -- maps a non-zero errcode.
  115.  
  116.     SYNOPSIS
  117.      size = regerror(code,preg,errbuf,errsize);
  118.                      a1   d2   d0     d1
  119.  
  120.      size_t regerror(int errcode, const regex_t *preg,char *errbuf, size_t errbuf_size);
  121.  
  122.     FUNCTION
  123.      Maps a non-zero errcode from either regcomp or regexec to a human-readable,
  124.      printable message. If preg is non-NULL, the error code should have arisen
  125.      from use of the regex_t pointed to by preg , and if the error code came
  126.      from regcomp , it should have been the result from the most recent regcomp
  127.      using that regex_t ( regerror may be able to supply a more detailed message
  128.      using information from the regex_t ).
  129.      regerror places the NULL-terminated message into the buffer pointed to by
  130.      errbuf , limiting the length (including the NULL) to at most errbuf_size
  131.      bytes. If the whole message won't fit, as much of it as will fit before
  132.      the terminating NULL is supplied. In any case, the returned value is the
  133.      size of buffer needed to hold the whole message (including terminating NULL).
  134.      If errbuf_size is 0, errbuf is ignored but the return value is still correct.
  135.  
  136.     INPUT
  137.      errcode - a regex positive error code
  138.      preg - a preg or NULL
  139.      errbuf - a buffer or NULL
  140.      errbuf_size - size of errbuf
  141.  
  142.     RESULT
  143.      Size to hold the complete error message.
  144. regex.library/regexec                           regex.library/regexec
  145.  
  146.     NAME
  147.      regexec -- matches a RE against a string.
  148.  
  149.     SYNOPSI
  150.      err = regexec(preg,string,nmatch,pmatch[],eflags);
  151.                    a1   d0     d1     d2       d3
  152.  
  153.      int regexec(const regex_t *preg, const char *string,
  154.                  size_t nmatch, regmatch_t pmatch[], int eflags);
  155.  
  156.     FUNCTION
  157.      Matches the compiled RE pointed to by preg against the string ,
  158.      subject to the flags in eflags , and reports results using nmatch ,
  159.      pmatch , and the returned value.
  160.      The RE must have been compiled by a previous invocation of regcomp .
  161.      The compiled form is not altered during execution of regexec ,
  162.      so a single compiled RE can be used simultaneously by multiple threads.
  163.  
  164.      By default, the NUL-terminated string pointed to by string
  165.      is considered to be the text of an entire line, minus any terminating
  166.      newline. The eflags argument is the bitwise OR of zero or more of the
  167.      following flags:
  168.      - REG_NOTBOL   The first character of the string is not the beginning of
  169.                     a line, so the `^' anchor should not match before it.
  170.                     This does not affect the behavior of newlines under REG_NEWLINE.
  171.      - REG_NOTEOL   The NUL terminating the string does not end a line, so the
  172.                     `$' anchor should not match before it. This does not affect
  173.                     the behavior of newlines under REG_NEWLINE.
  174.      - REG_STARTEND The string is considered to start at
  175.                     string + pmatch[0].rm_so
  176.                     and to have a terminating NUL located at
  177.                     string + pmatch[0].rm_eo
  178.                     (there need not actually be a NUL at that location),
  179.                     regardless of the value of nmatch .
  180.                     See below for the definition of pmatch and nmatch .
  181.                     This is an extension, compatible with but not specified
  182.                     by POSIX 1003.2, and should be used with caution in software
  183.                     intended to be portable to other systems.
  184.                     Note that a non-zero rm_so does not imply REG_NOTBOL;
  185.                     affects only the location of the string, not how it is
  186.                     matched.
  187.  
  188.      Normally, regexec returns 0 for success and the non-zero code REG_NOMATCH
  189.      for failure. Other non-zero error codes may be returned in exceptional
  190.      situations.
  191.  
  192.      If REG_NOSUB was specified in the compilation of the RE, or if nmatch
  193.      is 0, regexec ignores the pmatch argument (but see below for the case
  194.      where REG_STARTEND is specified). Otherwise, pmatch points to an array of
  195.      nmatch structures of type regmatch_t . Such a structure has at least the
  196.      members rm_so and rm_eo , both of type regoff_t (a signed arithmetic type
  197.      at least as large as an off_t and a ssize_t ), containing respectively the
  198.      offset of the first character of a substring and the offset of the first
  199.      character after the end of the substring.
  200.      Offsets are measured from the beginning of the string argument given to
  201.      regexec .
  202.      An empty substring is denoted by equal offsets, both indicating the
  203.      character following the empty substring.
  204.  
  205.      The 0th member of the pmatch array is filled in to indicate what substring
  206.      of string was matched by the entire RE.
  207.      Remaining members report what substring was matched by parenthesized
  208.      subexpressions within the RE;
  209.      member i reports subexpression i , with subexpressions counted
  210.      (starting at 1) by the order of their opening parentheses in the RE, left
  211.      to right. Unused entries in the array (corresponding either to
  212.      subexpressions that did not participate in the match at all, or to
  213.      subexpressions that do not exist in the RE (that is,
  214.      i > preg->re_nsub) (have both rm_so and rm_eo set to -1.
  215.      If a subexpression participated in the match several times, the reported
  216.      substring is the last one it matched.
  217.      (Note, as an example in particular, that when the RE `(b*)+' matches `bbb',
  218.      the parenthesized subexpression matches each of the three `b's and then
  219.      an infinite number of empty strings following the last `b',
  220.      so the reported substring is one of the empties.)
  221.  
  222.      If REG_STARTEND is specified, pmatch must point to at least one regmatch_t
  223.      (even if nmatch is 0 or REG_NOSUB was specified), to hold the input offsets
  224.      for REG_STARTEND. Use for output is still entirely controlled by nmatch ;
  225.      if nmatch is 0 or REG_NOSUB was specified, the value of pmatch [0] will not
  226.      be changed by a successful regexec .
  227.  
  228.     INPUTS
  229.      preg - a regular expression pointer
  230.      nmatch - number of element in pmatch
  231.      pmatch - holds result
  232.      eflags - flags
  233.  
  234.     RESULT
  235.      0 on matching or a positive regex error code.
  236. regex.library/regfree                              regex.library/regfree
  237.  
  238.     NAME
  239.      regfree -- free a RE .
  240.  
  241.     SYNOPSI
  242.      regfree(preg);
  243.              a0
  244.  
  245.      void regfree(regex_t *preg);
  246.  
  247.     FUNCTION
  248.      Frees any dynamically-allocated storage associated with the compiled RE
  249.      pointed to by preg . The remaining regex_t is no longer a valid compiled
  250.      RE and the effect of supplying it to regexec or regerror is undefined.
  251.  
  252.     INPUT
  253.      preg - a pointer to a reg expression compiled with recomp.
  254.  
  255.